package cglib;

import net.sf.cglib.beans.BeanCopier;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		/**
		// createProxyUsingNoOp
		TargetClass targetClass = (TargetClass) CGlibClassFactory.getInstance().createProxyUsingNoOp(TargetClass.class);
		targetClass.dosomthing();
		*/
		
		/**
		// createProxyUsingMethodInterceptor
		TargetClass targetClass = (TargetClass) CGlibClassFactory.getInstance().createProxyUsingMethodInterceptor(TargetClass.class);
		targetClass.dosomthing();
		*/
		
		/**
		// createProxyUsingFilter
		TargetClass targetClass = (TargetClass) CGlibClassFactory.getInstance().createProxyUsingFilter(TargetClass.class);
		targetClass.dosomthing();
		targetClass.donothing();
		*/
		
		/**
		// createProxyUsingFixedValue
		TargetClass targetClass = (TargetClass) CGlibClassFactory.getInstance().createProxyUsingFixedValue(TargetClass.class);
		System.out.println(targetClass.returnVlaue());
		*/
		
		/**
		// createProxyUsingLasyLoader
		WapperClass wapperClass = new WapperClass();
		TargetClass targetClass = wapperClass.getTargerClass();
		System.out.println("New WapperClass finish");
		targetClass.donothing();
		*/
		
		/**
		// copy
		BeanCopier copier = BeanCopier.create(CopyClass.class, CopyClass.class, false);
		
		CopyClass a = new CopyClass();
		
		CopyClass b = new CopyClass();
		
		copier.copy(a, b, null);
		
		System.out.println(a.getWapperClass());
		System.out.println(b.getWapperClass());
		*/
		
	}

}

class WapperClass{
	
	private int i = 1;
	
	private TargetClass targetClass = (TargetClass) CGlibClassFactory.getInstance().createProxyUsingLasyLoader(TargetClass.class);
	
	public TargetClass getTargerClass(){
		return targetClass;
	}
}

class CopyClass {
	
	WapperClass wapperClass = new WapperClass();

	public WapperClass getWapperClass() {
		return wapperClass;
	}

	public void setWapperClass(WapperClass wapperClass) {
		this.wapperClass = wapperClass;
	}
	
	
	
}